<template>
	<view class="personnelManagementAdd">
		<view class="personnelManagementAdd-content ff-bg-fff ff-font-14 ff-margin-12 ff-border-radius-10">
			<view class="ff-font-weight-600 ff-font-17 ff-margin-bottom-5">添加新员工</view>
			<view class="ff-flex-between ff-border-bottom">
				<view class="personnelManagementAdd-content-title">员工姓名</view>
				<input class="ff-text-right ff-line-height-1-3" placeholder="请输入" type="text"
					v-model.trim="addInfoList.username" />
			</view>
			<view class="ff-flex-between ff-border-bottom">
				<view class="personnelManagementAdd-content-title">员工手机号码</view>
				<input class="ff-text-right ff-line-height-1-3" maxlength="11" placeholder="请输入" type="number"
					v-model.trim="addInfoList.staffPhone" />
			</view>
		</view>
		<view class="ff-color-5C5F65 ff-font-13 ff-margin-top-15 ff-margin-left-25">
			员工默认登录密码：123456
		</view>
		<view class="personnelManagementAdd-but ff-margin-top-50">
			<view class="personnelManagementAdd-but-box"><u-button type="primary" shape="circle"
					@click="addSubmit">确认添加</u-button></view>
		</view>
		<u-toast ref="uToast" />
		<f-loading ref="loading" />
	</view>
</template>

<script>
	export default {
		name: 'personnelManagementAdd',
		data() {
			return {
				addInfoList: {
					username: '',
					staffPhone: ''
				}
			};
		},
		methods: {
			// 确认添加员工
			addSubmit() {
				if (this.addInfoList.username == '') {
					this.$refs.uToast.show({
						title: '请输入项目名称',
						type: 'error'
					});
					return;
				}
				if (!this.$check.isMobile(this.addInfoList.staffPhone)) {
					this.$refs.uToast.show({
						title: '请输入正确的手机号',
						type: 'error'
					});
					return;
				}
				this.$http.post({
					url: '/company/staff/add',
					data: this.addInfoList
				}).then(res => {
					// console.log('确认添加员工返回的数据--------', res)
					if (res.code == 200) {
						this.$refs.uToast.show({
							title: res.msg,
							type: 'success'
						});
						this.$pageJump.reLaunch(
							'/pages/detection/company/home/components/personnelManagement/personnelManagement')
					} else {
						this.$refs.uToast.show({
							title: res.msg,
							type: 'error'
						});
					}
				})
			}
		},
		onShareAppMessage() {
			return {
				title: '分享小程序给朋友',
				path: '/pages/homePage/Home'
			};
		}
	};
</script>

<style lang="scss" scoped>
	.personnelManagementAdd {
		&-content {
			padding: 40rpx 30rpx 32rpx;

			.ff-border-bottom {
				padding: 40rpx 0;
				align-items: center;

				input {
					height: 28rpx;
					line-height: 1;
				}
			}

			&-title {
				color: #2a3c62;
			}
		}

		&-but {
			&-box {
				margin: 0 5%;

				/deep/.u-size-default {
					height: 90rpx !important;
					line-height: 90rpx !important;
				}
			}
		}
	}
</style>